import request from '@/untils/request.js'

//查询所有住户
export const queryAllHouseholdersService = (currentPage, pageSize) => {
    return request.get('/queryHouseholders', { params: { currentPage, pageSize } })
}

//根据身份证查询住户
export const queryHouseholderService = (householderCard) => {
    return request.get('/queryHouseholder', { params: { householderCard } })
}

//添加住户
export const addHouseholderInfoService = (householderData) => {
    // 将注册数据转换为JSON字符串
    const jsonData = JSON.stringify(householderData);
    // 设置请求头为application/json
    const config = {
        headers: {
            'Content-Type': 'application/json'
        }
    };
    return request.post('/addHouseholder', jsonData, config);
}

//修改住户信息
export const updateHouseholderInfoService = (newHouseholderInfo) => {
    return request.put('/updateHouseholder', newHouseholderInfo)
}

//删除用户
export const deleteHouseholderService = (householderId) => {
    // 使用模板字符串来构建 URL
    return request.delete(`/deleteHouseholderById/${householderId}`)
}

//更新住户车牌
export const updateHouseholderCarService = (licensePlate) => {
    return request.put('/updateHouseholderCar', licensePlate)
}